GBML manual / Maths

max

The larger of a and b.

Syntax

max(a, b) -> real

Arguments

NameType
areal
breal

Returns

real

Description

The larger of a and b.

Given two whole numbers, max hands back a whole number; if either one is a decimal, the answer is a decimal. max_int does the same for whole numbers but refuses a decimal outright.

Example

hsp = max(hsp - 1, -3);

Accelerates this object leftward by 1 every frame, but never past a top speed of 3 the other way - once hsp - 1 would go lower than -3, max keeps handing back -3 instead. min's own example caps the opposite direction; together they are a top speed on both sides. clamp does both at once against two fixed bounds in one call.

Cost

One comparison - as cheap as this group gets, safe to call every frame.

On the GBA

min’s own twin (the GBA module’s own max) - one comparison. When both numbers are whole numbers the answer is a whole number too; if either is a decimal the answer is a decimal. max_int is the same call, for when you want a decimal refused outright.

See also: minclampmax_int